﻿using System.Windows;
using System.Net;
using System;
using System.Xml;
using System.Collections.Generic;
using Jok.Client.Loader;
using Jok.Client.Infrastructure;

namespace Jok.Client.Loader
{
    public partial class App
    {
        public static PackagesManager PackagesManager { get; set; }

        public App()
        {
            PackagesManager = new PackagesManager();

            this.Startup += this.Application_Startup;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Show Loader
            PackagesManager.LoaderView = new LoadingView();
            this.RootVisual = (LoadingView)PackagesManager.LoaderView;

            // Start Loading
            if (!App.PackagesManager.StorageMemoryRequired)
                App.PackagesManager.StartLoading();
        }
        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.ExceptionObject.Message);

            e.Handled = true;
        }
    }
}
